const router = require('koa-router')()
// 页面路径配置
const routerConfig = require('./router-config')


// 装载 router
routerConfig.map((item, i) => {

    let type = item.type || 'get'
    let action = item.action || 'indexPage'
    router[type](item.path, require(item.controll)[action])

    // 判断children
    item.children && item.children.map((citem, ci) => {
        let ctype = citem.type || 'get'
        let caction = citem.action || 'indexPage'
        router[ctype](item.path + citem.path, require(citem.controll)[caction])
    })

    router.use('', router.routes(), router.allowedMethods())

})


module.exports = router